package com.probiz.estore.content.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.probiz.estore.common.model.content.Content;
import com.probiz.estore.content.dao.AutoEvalRelatedContentDao;
import com.probiz.estore.content.model.ContentConstants;
import com.probiz.estore.content.service.AutoEvalRelatedContentManager;
import com.probiz.estore.core.service.impl.GenericManagerImpl;

public class AutoEvalRelatedContentManagerImpl  extends GenericManagerImpl<Content> implements AutoEvalRelatedContentManager{
	private AutoEvalRelatedContentDao  autoEvalRelatedContentDao;
	
	public void setAutoEvalRelatedContentDao(
			AutoEvalRelatedContentDao autoEvalRelatedContentDao) {
		this.autoEvalRelatedContentDao = autoEvalRelatedContentDao;
	}

	@Override
	protected void initManager() {
		dao = autoEvalRelatedContentDao;
		
	}

	@Override
	protected void preDelete(Content entity) {
		
	}

	@Override
	protected void preSave(Content entity) {
		
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.content.service.AutoEvalRelatedContentManager#getSameKeywordsContentsBySourceId(java.lang.Integer, int, int)
	 */
	public List<Content> getSameKeywordsContentsBySourceId(Integer sourceId, int firstResult, int maxResults) {
		return autoEvalRelatedContentDao.getSameKeywordsContentsBySourceId(sourceId, firstResult, maxResults);
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.content.service.AutoEvalRelatedContentManager#getNewestContentsBySourceId(java.lang.Integer, int, int)
	 */
	public List<Content> getNewestContentsBySourceId(final Integer sourceId,	final int firstResult, final int maxResults){
		return autoEvalRelatedContentDao.getNewestContentsBySourceId(sourceId, firstResult, maxResults);
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.content.service.AutoEvalRelatedContentManager#getViewCountContentsBySourceId(java.lang.Integer, int, int)
	 */
	public List<Content> getViewCountContentsBySourceId(final Integer sourceId,	final int firstResult, final int maxResults){
		return autoEvalRelatedContentDao.getViewCountContentsBySourceId(sourceId, firstResult, maxResults);
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.content.service.AutoEvalRelatedContentManager#getContentsByRuleCodeBySourceId(java.lang.Integer, java.lang.Integer, int, int)
	 */
	public List<Content> getContentsByRuleCodeBySourceId(final Integer ruleCode, final Integer sourceId, final int firstResult, final int maxResults){
		switch (ruleCode.intValue()) {
			case ContentConstants.RELATED_RULE_CODE_KEYWORDS:
				return this.getSameKeywordsContentsBySourceId(sourceId, firstResult, maxResults);
			case ContentConstants.RELATED_RULE_CODE_NEWEST:
				return this.getNewestContentsBySourceId(sourceId, firstResult, maxResults);
			case ContentConstants.RELATED_RULE_CODE_VIEWCOUNT:
				return this.getViewCountContentsBySourceId(sourceId, firstResult, maxResults);	
			default:
				return new ArrayList<Content>();
		}
	}
}
